package com.csw.compose.ui.module.component.container

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.csw.compose.theme.pagePadding
import com.csw.compose.ui.Destination
import com.csw.compose.ui.components.BodyText
import com.csw.compose.ui.components.LabelText
import com.csw.compose.ui.components.PrimaryTitle
import com.csw.compose.ui.components.UlItem
import com.csw.compose.ui.module.BasePage

@Preview
@Composable
fun BoxPreview() {
    BasePage({}, "盒子组件（Box）") { BoxPage() }
}

class BoxData {
    companion object : Destination("BoxPage")
}

@Composable
fun BoxPage(){
    Column(
        modifier = Modifier
            .padding(horizontal = pagePadding)
            .verticalScroll(rememberScrollState())
    ) {
        PrimaryTitle("简介")
        BodyText("Box组件类似FrameLayout，用于子组件层叠排布")
        Box(Modifier.size(80.dp)) {
            Box(Modifier.size(40.dp).alpha(0.5f).background(Color.Red))
            Box(Modifier.offset(20.dp,20.dp).size(40.dp).alpha(0.5f).background(Color.Green))
            Box(Modifier.offset(40.dp,40.dp).size(40.dp).alpha(0.5f).background(Color.Blue))
        }

        UlItem("contentAlignment")
        LabelText("内容对齐，默认对齐左上角，按九宫格划分，可以对齐四周八个方向或居中")
        Box(Modifier.fillMaxWidth().height(300.dp).border(2.dp,Color.Gray),contentAlignment = Alignment.Center) {
            Box(Modifier.offset((-20).dp, (-20).dp).size(40.dp).alpha(0.5f).background(Color.Red))
            Box(Modifier.size(40.dp).alpha(0.5f).background(Color.Green))
            Box(Modifier.offset(20.dp,20.dp).size(40.dp).alpha(0.5f).background(Color.Blue))
        }


    }
}